package fmglemmings;

import java.util.logging.Logger;

/**
 * Epito Lemming osztaly
 */
public class BuilderLemming extends Lemming {
	
	private static Logger logger = Logger.getLogger("fmglemmings");
	private int remainingBricks; 
	private boolean building=false;
	private boolean buildstarted=false;
	
    /**
     * utemenkent ellenorzi epitette e mar a lemming, ha igen, de ebben a korben nem kell, akkor visszavaltozik normal lemmingge
     */
	public void tickEvent() {
		if(building){
			if(!buildstarted)buildstarted=true;
			building=false;
		}else{
			if(buildstarted)gf.changeRequest(this);
		}
	}

    /**
     * a fallEvent feluldefinialasa. Ekkor ugyanis nem zuhannia kell, hanem epitenie.
     */
        public void fallEvent() {
		building=true;
		if(remainingBricks>0){
			remainingBricks--;
			gf.buildRequest(this);
                        if (remainingBricks==0){
                            gf.turnRequest(this);
                            gf.changeRequest(this);
                        }
			logger.info("hatralevo kovek:"+remainingBricks);
		}
        }
    /**
     * konstruktor
     * @param a X koordinata
     * @param b Y koordinata
     * @param c irany
     */
	public BuilderLemming(int a, int b, int c){
                super(a,b,c);
		remainingBricks=5;
                logger.info("Konstruktor kesz X:"+X+" Y: "+Y);
	}
	 
}
 
